﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Role.aspx.cs" Inherits="WMS6.Web.Administration.Role" meta:resourcekey="Page" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Role</title>
    <link href="../style/zh/1/css.css" type="text/css" rel="Stylesheet" id="mycss" />
    <link href="../Css/style.css" type="text/css" rel="stylesheet" />
    <script src="../Js/jquery.js" type="text/javascript"></script>
    <script src="../Js/jquery.simplemodal.js" type="text/javascript"></script>
    <script src="../Js/util.js" id="js" type="text/javascript"></script>
    <script src="../Js/InitPage.js" type="text/javascript"></script>    
    <script src="../Js/jquery.blockUI.js" type="text/javascript"></script>
     <script src="../Js/Ajax.js" type="text/javascript"></script>
    <script type="text/javascript">
     //初始化页面样式
            initEditNewPage(); 
        function ddlonchange() {
            bodyonload(); //当变换 角色名称 重新加载页面数据
        }
        //页面初始化加载
        function bodyonload()
         {       
            $.blockUI.defaults.message = GetBlockUIMsg();
            $.blockUI.defaults.overlayCSS.backgroundColor = GetBlockUIBgColor();
            $.blockUI(); // 页面加锁屏
            NameAuthentications();
        }
        //整体加载请求
        function NameAuthentications() {
            var Url = "../Common/RoleAjax.aspx?Type=1&id=-1&RoleId="+ escape(document.getElementById('<%=txtRoleId.ClientID%>').value); 
            XmlHttp.sendReq(Url, handleStateChanges);
        }
        //整体返回数据
        function handleStateChanges(obj) {
            document.getElementById('TreeData').innerHTML = obj.responseText;
            $.unblockUI();
        }
        ///异步请求
        /// type 第几级 /Id 编号  /Name 名字/ Status 状态 /false 有 没选择中的 true是 全部被选中
        function Load(Id, Name, type, Status) {
            if (document.getElementById( Id + Name +type +'_div').style.display == '') //判断 当前的是否已经被展开
            {
                document.getElementById(Id + Name + type + '_div').style.display = 'none';  //折叠起来
                document.getElementById(Id + Name + type + '_img').src = '../Images/smalladdition.gif';  //替换折叠的图片navigation_tree_expanded
                return;
            }
            if (document.getElementById(Id + Name + type + '_ClassHid').value != "")  //判断当前的隐含域是否为空 不等于空代表他已经被加载过 不需要在去访问AJAX方法
            {
                document.getElementById(Id + Name + type + '_div').style.display = ''; //  直接显示
                document.getElementById(Id + Name + type + '_img').src = '../Images/-.gif'; //替换显示图片
                return;
            }
            document.getElementById('hidId').value = Id + Name +type;   // 把传入的类型与名字 与ID 保存在页面级别隐含域
            document.getElementById(Id + Name + type + '_img').src = '../Images/ajaxData-loader.gif';  //替换出加载图片
            var Url = "../Common/RoleAjax.aspx?Type=" + type + '&Id=' + Id + '&Name=' +escape(Name) + '&Status=' + Status;
            XmlHttp.sendReq(Url, LoadhandleStateChange);
        }
        function LoadhandleStateChange(obj) {
            ajaxData = obj.responseText;
            ajaxData = ajaxData.split("@_@");
            if (ajaxData[2] != null) {
                document.getElementById(ajaxData[2] + '_div').innerHTML = ajaxData[0];
                document.getElementById(ajaxData[2] + '_ClassHid').value = ajaxData[1];
                if (document.getElementById('hidType').value.length == 1) {
                    document.getElementById(ajaxData[2] + '_div').style.display = '';
                    document.getElementById(ajaxData[2] + '_img').src = '../Images/-.gif';

                }
                else {
                    document.getElementById('hidType').value = document.getElementById('hidType').value.substring(0, document.getElementById('hidType').value.length - 1);
                    document.getElementById(ajaxData[2] + '_img').src = '../Images/smalladdition.gif';
                    if (ajaxData[1] != null && ajaxData[1] != "") {
                        CheckClassHid(ajaxData[1], document.getElementById(ajaxData[2] + '_CheckBox').checked);
                    }
                }
            }
        }
        function CheckIn(obj, status) {
            //根据传入的obj 来获取他的check的是被选种还是未选种
            var Type = document.getElementById(obj + '_CheckBox').checked;
            //根据获取到父类的值来给子类赋值
            if (Type) {
                document.getElementById(obj + '_font').style.color = "Black"; //变色
                if (document.getElementById(obj + '_ClassHid').value == "Lower") 
                {
                    document.getElementById("<%=hidButtonTrue.ClientID %>").value += document.getElementById(obj + "_CheckHid").value + ',';
                    document.getElementById("<%=hidButtonFalse.ClientID %>").value = document.getElementById("<%=hidButtonFalse.ClientID %>").value.replace(document.getElementById(obj + "_CheckHid").value + ',', ""); //替除ID
              
                }
                else 
                {
                    if (document.getElementById(obj + '_ClassHid').value != "") 
                    {                      
                        Check(obj);
                    }
                    else
                    {                  
                        CheckClassHidLoad(obj);
                    }
                }
            }
            else {
                document.getElementById(obj + '_font').style.color = "gray"; //变色
                if (document.getElementById(obj + '_ClassHid').value == "Lower") {
                                  
                    document.getElementById("<%=hidButtonFalse.ClientID %>").value += document.getElementById(obj + "_CheckHid").value + ',';
                    document.getElementById("<%=hidButtonTrue.ClientID %>").value = document.getElementById("<%=hidButtonTrue.ClientID %>").value.replace(document.getElementById(obj + "_CheckHid").value + ',', ""); //替除ID
//                
                }
                else {
                    if (document.getElementById(obj + '_ClassHid').value != "") {
                        Check(obj);
                    }
                    else 
                    {
                        CheckClassHidLoad(obj);
                    }
                }
            }
            if (status == 0) {
                CheckUp(Type, obj);
            }
        }
        //           //便利父接点
        function CheckUp(type, obj) {
            if (document.getElementById(obj + '_ParentHid') != undefined) {
                var Parent = document.getElementById(obj + '_ParentHid').value;
                if (Parent != "") //取得父级隐含于 判断如果不等于空的话！
                {
                    var hidData = document.getElementById(Parent + '_ClassHid').value.split(',');                 
                    var Check = 0; ;
                    for (var i = 0; hidData.length > i; i++) {
                        if (document.getElementById(hidData[i] + '_CheckBox').checked == type) {
                            Check++;
                        }
                    }

                    if (Check == hidData.length) {
                        if (document.getElementById(Parent + '_CheckBox') != undefined) {

                            var Checked = "";
                            if (type) {
                                Checked = "checked=\"checked\"";
                                document.getElementById(Parent + '_font').style.color = "Black";
                            }
                            if (document.getElementById(Parent + '_A') != undefined) {
                                //如果不等于 undefined 那么 替换A元素以前的 img 半选图片   让他成为check
                                document.getElementById(Parent + '_A').innerHTML = "<input type=\"checkbox\" id=\"" + Parent + "_CheckBox\" onclick=\"JavaScript:Check('" + Parent + "')\" " + Checked + " />";
                            }
                            else {
                                document.getElementById(Parent + '_CheckBox').checked = type;
                            }
                        }
                    }
                    else {

                        if (document.getElementById(Parent + '_CheckBox') != undefined) {
                            document.getElementById(Parent + '_CheckBox').checked = true;

                        }
                        document.getElementById(Parent + '_font').style.color = "gray";
                    }
                }
                CheckUp(type, Parent);
            }
        }
        //修改字体颜色并且加载子菜单
        function Check(obj, status) {
            //根据传入的obj 来获取他的check的是被选种还是未选种
            var Type = document.getElementById(obj + '_CheckBox').checked;          
            //根据获取到父类的值来给子类赋值
            if (Type) 
            {          
                document.getElementById(obj + '_font').style.color = "Black"; //变色
                if (document.getElementById(obj + "_CheckHid") != undefined )
                 {                    
                    if (document.getElementById(obj + '_ClassHid').value != "Lower" )
                     {
                        if(document.getElementById(obj + '_Type') != undefined )
                        {
                           if(document.getElementById(obj + '_Type').value ==4 )
                           { 
                            document.getElementById("<%=hidFunctionTrue.ClientID %>").value += document.getElementById(obj + "_CheckHid").value + ',';
                            document.getElementById("<%=hidFunctionFalse.ClientID %>").value = document.getElementById("<%=hidFunctionFalse.ClientID %>").value.replace(document.getElementById(obj + "_CheckHid").value + ',', ""); //替除ID
                           }
                        }                       
                    }
                 else
                    {
                    
                    
                     document.getElementById("<%=hidButtonTrue.ClientID %>").value += document.getElementById(obj + "_CheckHid").value + ',';
                     document.getElementById("<%=hidButtonFalse.ClientID %>").value = document.getElementById("<%=hidButtonFalse.ClientID %>").value.replace(document.getElementById(obj + "_CheckHid").value + ',', ""); //替除ID
                  
//                
                    }
                }
              
            }
            else
             {            
                document.getElementById(obj + '_font').style.color = "gray"; //变色
                if (document.getElementById(obj + '_ClassHid').value != "Lower") 
                {
                    if (document.getElementById(obj + "_CheckHid") != undefined ) 
                    {
                     if(document.getElementById(obj + '_Type') != undefined )
                        {
                           if(document.getElementById(obj + '_Type').value ==4 )
                           { 
                             document.getElementById("<%=hidFunctionFalse.ClientID %>").value += document.getElementById(obj + "_CheckHid").value + ',';
                             document.getElementById("<%=hidFunctionTrue.ClientID %>").value = document.getElementById("<%=hidFunctionTrue.ClientID %>").value.replace(document.getElementById(obj + "_CheckHid").value + ',', ""); //替除ID
                           } 
                         }  
                          
                    }
                }
                 else
                    {                  
                      document.getElementById("<%=hidButtonFalse.ClientID %>").value += document.getElementById(obj + "_CheckHid").value + ',';
                      document.getElementById("<%=hidButtonTrue.ClientID %>").value = document.getElementById("<%=hidButtonTrue.ClientID %>").value.replace(document.getElementById(obj + "_CheckHid").value + ',', ""); //替除ID
//               
                    }
            }
          if (status == 0) {
                CheckUp(Type, obj);

            }
            if (document.getElementById(obj + '_ClassHid').value == "") //如果他的子隐含于等于空那么 继续加载字的隐含于
            {
                CheckClassHidLoad(obj);
            }
            else {
                if (document.getElementById(obj + '_ClassHid').value == "Lower") {
                    CheckIn(obj, 1);
                }
                else {
                    var ClassName = document.getElementById(obj + '_ClassHid').value.split(','); //获取到子集合的记录
                    for (var i = 0; ClassName.length > i; i++) 
                    {
                      try
                      {
                        document.getElementById(ClassName[i] + '_CheckBox').checked = document.getElementById(obj + '_CheckBox').checked

                        if (document.getElementById(ClassName[i] + '_ClassHid').value == "Lower") 
                        {
                            CheckIn(ClassName[i], 1);
                        }
                        else {
                            CheckIn(ClassName[i], 1);
                        }
                      }
                      catch(e)
                      {
                      
                      }  
                    }
                }
            }
        }
        //加载子方法
        function CheckClassHidLoad(name) 
        {
            try
             {
                document.all(name + '_Aclick').click(); //调用 本级的加载子菜单的方法
             }
            catch (e)
             {
            
             }

            document.getElementById('hidType').value += 1;
        }
        //加载完毕子方法后继续处理
        function CheckClassHid(obj, type) {
            var ClassName = obj.split(',');
            for (var i = 0; ClassName.length > i; i++) {
               try
               {
                document.getElementById(ClassName[i] + '_CheckBox').checked = type;
                Check(ClassName[i], 1);
                }
                catch(e)
                {
                
                }
            }
        }
        function CheckTrueOrFalse(name) {
            document.getElementById(name + '_A').innerHTML = "<input type=\"checkbox\" id=\"" + name + "_CheckBox\" onclick=\"JavaScript:Check('" + name + "')\" checked=\"checked\" />";
            document.getElementById(name + '_font').style.color = "Black";  //并且变换他的颜色成为黑色
            document.getElementById(name + '_CheckBox').checked = true;
            if (document.getElementById(name + '_ClassHid') != undefined && document.getElementById(name + '_ClassHid').value != "") {
                CheckClassHid(document.getElementById(name + '_ClassHid').value, true);
            }
        }
        function Copy() {

            if (document.getElementById('txtRoleId').value != '') {
                document.getElementById('hdnCopy').value = document.getElementById('txtRoleId').value;
                document.getElementById('txtRoleId').disabled = ""
                document.getElementById('txtRoleId').value = "";
                document.getElementById('txtRoleName').value = "";
                document.getElementById('chkIsActive').checked = true;
                document.getElementById('chkSysCreated').checked = false;
                document.getElementById('hdnFlag').value = "0";
            }
        }
        function confirmMsg(code) {
            if (code == "F1650_007") {
                if (confirm('<%=GetGlobalMsgResource("F1650_007") %>')) {
                    return true;
                }
                else {
                    return false;
                }
            }
        }
    </script>

</head>
<body  onload="bodyonload();" >
    <form id="F1011" runat="server">
    <div>
        
        <div id="div_top">
            <table>
                <tr >
                    <td valign="bottom"><asp:Label ID="lblOwner" runat="server" CssClass="label_header" 
                            Text="角色" meta:resourcekey="lblOwner"></asp:Label></td>
                    <td><asp:Button ID="btnGoBack" runat="server" CssClass="button" Enabled="False" 
                            Text="<%$Resources:ButtonResource,btnGoBack%>"  onclick="btnGoBack_Click"  /></td>
                    <td><asp:Button ID="btnNew" runat="server" CssClass="button" Enabled="False" 
                            Text="<%$Resources:ButtonResource,btnNew%>"  AccessKey="n" OnClick="btnNew_Click" 
                            /></td>
                    <td><asp:Button ID="btnSave" runat="server" CssClass="button" Enabled="False" 
                            Text="<%$Resources:ButtonResource,btnSave%>" AccessKey="s" onclick="btnSave_Click" 
                              /></td>
                    <td><asp:Button ID="btnDelete" runat="server" CssClass="button" Enabled="False" 
                            Text="<%$Resources:ButtonResource,btnDelete%>"  AccessKey="d" OnClientClick="javascript:if(confirmMsg('F1650_007')) return true; else return false;" 
                           onclick="btnDelete_Click" /></td>
                    <td><asp:Button ID="btnCopy" runat="server" CssClass="button" Enabled="False" Text="<%$Resources:ButtonResource,btnCopy%>" 
                            AccessKey="c"  OnClientClick="Copy(); return false;" 
                             /></td> 
                </tr>
            </table>
        </div>
        
        <div>
            <asp:Label ID="lblMsg" runat="server" CssClass="label_message" 
                meta:resourcekey="lblMsg"></asp:Label>
        </div>
        <div id="div_menu">
            <div style="float: left; width: 8px;">
                <div class="tabL" id="imgL1"></div>
            </div>
            <div class="tabLabelCont tabCur" id="div1">
                <span id="one1" class="hover">角色设置</span></div>
            <div style="float: left; margin-right: 2px;">
                <div class="tabR" id="imgR1"></div>
            </div>
        </div>
        
        <div id="div_content">
             <div id="con_one_1" style="display: block;">
               <div id="Div2" style="display:block;">
    <table width="500px;" style="display:block;margin-left:10px;margin-top:10px;">
        <tr>
            <td><asp:Label ID="lblRoleId" CssClass="label" runat="server" Text="角色" 
                    meta:resourcekey="lblRoleId"></asp:Label></td>
       
        </tr>
        <tr>
            <td><asp:TextBox ID="txtRoleId" runat="server" CssClass="textbox" MaxLength="20" 
                    meta:resourcekey="txtRoleId"></asp:TextBox></td>
        </tr>
   
        <tr>
            <td><asp:Label ID="lblRoleName" CssClass="label" runat="server" Text="描述" 
                    meta:resourcekey="lblRoleName"></asp:Label></td>
        </tr>
        <tr>
            <td><asp:TextBox ID="txtRoleName" runat="server" CssClass="textbox" 
                    meta:resourcekey="txtRoleName"></asp:TextBox></td>
        </tr>
        <tr>
            <td><asp:CheckBox ID="chkIsActive" runat="server" CssClass="checkbox" Text="启用" 
                    Checked="True" meta:resourcekey="chkIsActive" /></td>
          
        </tr>
        <tr>
             <td><asp:CheckBox ID="chkSysCreated" runat="server" Enabled="False" 
                     CssClass="checkbox" Text="系统创建" meta:resourcekey="chkSysCreated" /></td> 
        </tr>
    </table>
  </div>
  <br />
  <div style ="margin-left:20px" id="TreeData" >
   </div>
    <input id="hidStatus" type="hidden" />
     <input id="hidId" type="hidden"  />
     <input id="hidType" type="hidden" value=0 />
     
      <input id="hidButtonTrue" runat="server" type="hidden"  />
       <input id="hidButtonFalse" runat="server" type="hidden"  />
             <input id="hidFunctionTrue" runat="server" type="hidden"  />
       <input id="hidFunctionFalse" runat="server" type="hidden"  />   
             </div>
         </div>

    </div>
        <input type="hidden" id="hdnFrom" runat="server" />
        <input type="hidden" id="hdnCopy" runat="server" />
         <input type="hidden" id="hdnFlag" runat="server" />
    </form>
</body>
</html>
